#ifndef __TYPES_H__
#define __TYPES_H__

#ifndef WIN32
#define scanf_s scanf
#endif

typedef unsigned long long  U64;
typedef long long           S64;
typedef unsigned int        U32;
typedef int                 S32;
typedef unsigned short int  U16;
typedef short int           S16;
typedef unsigned char       U8;
typedef char                S8;

// specific variable types
typedef U32                 BOOL;
typedef U8                  BYTE;
typedef S8                  CHAR;
typedef S64                 FP;             // fixed point

#define NULL                0           // void or invalid pointer
#define FAIL                0           // function return (failed)
#define OK                  1           // function return (success)
#define TRUE                1           // boolean
#define FALSE               0           // boolean

typedef struct
{
	double x;
	double y;
	double z;
} POINT;

typedef struct 
{
	FP x;
	FP y;
	FP z;
}FP_POINT;

typedef struct
{
	FP a;
	FP_POINT p;
}SIMPLE_CUBE;


typedef struct 
{
	FP a;
	FP_POINT p;
	U8 io_vertices[8];

}CUBE;

typedef struct
{
	U8	polyhedronType;
	U8	computationMethod;
	U16 maximumRecursion; 
}SETTINGS;

typedef struct
{
	FP sum;
	FP error;
	double computationTime;
	S64 calls;
}MAGGOTRESPONSE;

enum
{
	POLY_TETRAHEDRON 	= 1,
	POLY_CUBE		 	= 2,
	POLY_OCTAHEDRON  	= 3,
	POLY_DODECAHEDRON	= 4,
	POLY_ICOSAHEDRON	= 5,
};

enum
{
	METHOD_MEMORY	= 1,
	METHOD_NOMEMORY,
};


#define MIN(a, b)               ((a) < (b) ?  (a) : (b))
#define MAX(a, b)               ((a) > (b) ?  (a) : (b))
#define ABS(a)                  ((a) < 0   ? -(a) : (a))
#define SGN(a)                  ((a) < 0   ? (-1) : (1))
#define COPY(dst,src)			(memcpy(&dst,&src,sizeof(src)))

#endif